import { platformOrderListColumns } from './platformOrderList.config.js'
import search from './../search/search.js';
import { purchaseRejectedinfoPageList, notifyPlatformSupplyConfirm } from '@/api/supplier/procurementReturn.js'
export default {
    name: "platformOrderList",
    mixins: [search],
    data() {
        return {
            platformOrderListColumns,
            loading: false,
            loadData: [{
                id: 1,
            }],
            page: {
                current: 1,
                total: 0,
                size: 10
            },
            selectedRows: [],//选中的数组
            selectedRowKeys: [],  //选中的数组
            number: 0,
            btn: [
                // {
                //     title: "导出",
                //     isShow: true
                // },
            ],
            searchForm:{}
        }
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                console.log(searchForm)
                this.searchForm = searchForm
            }
            if (page) {
                this.page.current = page
            }
            purchaseRejectedinfoPageList(Object.assign({deptId: this.$store.getters.userInfo.sysUser.deptId, tenantId: this.$store.getters.userInfo.sysUser.tenantId}, this.searchForm, this.page)).then(val => {
                console.log(val)
                let data = val.data
                this.page = {
                    current: data.current,
                    total: data.total,
                    size: data.size,
                }
                this.loadData = data.records
                this.$emit("trigger")
            })
            this.$emit("trigger")
        },
        onShowSizeChange(current, size) {
            console.log(current, size)
            this.page.current = current
            this.page.size = size
            this.getList()
        },
        onSelectChange(selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys
            this.selectedRows = selectedRows;
            this.number = this.selectedRows.length
        },
        // 清空选中项
        clearSelection() {
            this.selectedRowKeys = []
            this.number = 0
        },
        handler(index) {
            if (index == 0) {
                this.platformOrderList()
            }
        },
        // 导出
        platformOrderList() {

        },
        out(item) {
            var that = this
            this.$confirm({
                title: '是否确认退货？',
                onOk() {
                    notifyPlatformSupplyConfirm(item.id).then(()=>{
                        that.$message.success('退货成功');
                        that.getList()
                    })
                },
                onCancel() { },
            });
        },
        details(item) {
            this.$router.push({
                path: "/supplier/procurementReturn/platformOrderList/inDetails", query: {
                    rejectedInfoId: item.rejectedInfoId,
                    xiangqing: 0,
                    status: item.status,
                    id: item.id
                }
            })
        }
    }

} 